import Vue from 'vue'
import VueRouter from 'vue-router'
import EmpView from '../views/tlias/EmpView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: '/main'
  },
  {
    path: '/main',
    name: 'main',
    component: () => import('../views/tlias/MainView.vue'),
    // 默认跳转到'/main/dept'
    // redirect: '/main/emp',
    children: [
      {
        path: '/main/emp',
        name: 'emp',
        component: EmpView
      },
      {
        path: '/main/dept',
        name: 'dept',
        component: () => import('../views/tlias/DeptView.vue')
      },
    ]
  },
  {
    path: '/404',
    component: () => import('../views/404View.vue')
  },
  // 若是上面的路由都无法匹配，则使用下面的路由规则
  {
    path: '*',
    redirect: '/404'
  },
]

const router = new VueRouter({
  routes
})

export default router
